package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.entity.NursingProject;
import com.zzyl.mapper.NursingProjectMapper;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectPageVo;
import com.zzyl.vo.NursingProjectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description NursingProjectServiceImpl
 * @Author xzy
 * @Date 2025-05-08  16:58
 */
@Service
public class NursingProjectServiceImpl implements NursingProjectService {

    @Autowired
    private NursingProjectMapper nursingProjectMapper;

    /**
     * 分页查询
     *
     * @param nursingProjectPageVo
     * @return
     */
    @Override
    public PageResponse<NursingProjectVo> pageNursingProjects(NursingProjectPageVo nursingProjectPageVo) {
        PageHelper.startPage(nursingProjectPageVo.getPageNum(), nursingProjectPageVo.getPageSize());
        Page<NursingProjectVo> page = nursingProjectMapper.pageNursingProjects(nursingProjectPageVo.getName(), nursingProjectPageVo.getStatus());
        return PageResponse.of(page, NursingProjectVo.class);
    }

    @Override
    public void addNursingProject(NursingProjectVo nursingProjectVo) {
        NursingProject nursingProject = BeanUtil.copyProperties(nursingProjectVo, NursingProject.class);
        nursingProjectMapper.addNursingProject(nursingProject);
    }

    @Override
    public NursingProjectVo getNursingProjectById(Long id) {
        NursingProject nursingProject = nursingProjectMapper.getNursingProjectById(id);
        return BeanUtil.copyProperties(nursingProject, NursingProjectVo.class);
    }

    @Override
    public void modifyNursingProject(NursingProjectVo nursingProjectVo) {
        NursingProject nursingProject = BeanUtil.copyProperties(nursingProjectVo, NursingProject.class);
        nursingProjectMapper.modifyNursingProject(nursingProject);
    }

    @Override
    public void removeNursingProject(Long id) {
        nursingProjectMapper.removeNursingProject(id);
    }

    @Override
    public void enableOrDisable(Long id, Integer status) {
        nursingProjectMapper.enableOrDisable(id, status);
    }

}
